package com.dong.bean;

import com.dong.config.T040PropertyValueConfig;
import org.springframework.beans.factory.annotation.Value;

/**
 * 用于测试@Value
 * @see T040PropertyValueConfig
 */
public class PersonValue {
    /**
     * 使用@Value
     * 1. 基本数值
     * 2. 可以写spel #{}  ${}
     *  3. 可以写${}  取出配置文件中的值, (在环境中的值)
     */
    @Value("王五")
    private String name;
    @Value("#{20-3}")   //spel
    private Integer age;
    @Value("${personValue.nickname}") //@PropertySource()
    private String nickName;

    public PersonValue() {
    }

    public PersonValue(String name, Integer age) {
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public String getNickName() {
        return nickName;
    }

    public void setNickName(String nickName) {
        this.nickName = nickName;
    }

    @Override
    public String toString() {
        return "PersonValue{" +
                "name='" + name + '\'' +
                "nickName='" + nickName + '\'' +
                ", age=" + age +
                '}';
    }
}
